CSCI E-92: Application Note 11 SVCs called from inside supervisor handler code ----------------------------------------------- Supervisor calls cannot be issued from within supervisor call handler code. In the ARM v7-M Architecture Reference Manual, ARM DDI 0403Derrata 2010_Q3 (ID100710), section B1.5.4, subsection "Priority escalation" on page B1-640 it states: When the current execution priority is less than HardFault, the processor escalates the exception priority to HardFault in the following cases: o When the group priority of a pending synchronous fault or supervisor call is lower than or equal to the currently executing priority, inhibiting normal preemption. This applies to all synchronous exceptions, both faults and SVCalls. This includes a DebugMonitorFault caused by executing a BKPT instruction, but excludes all other DebugMonitorFaults. o If a disabled configurable-priority fault occurs. Because of the first bullet point above, issuing an SVC within an SVC handler causes a HardFault to occur on the nested SVC instruction. When the SVC handler code is running, it runs at the priority assigned to SVC handler code. In our case, the priority of the SVC handler code is set by calling the svcInit_SetSVCPriority procedure in svc.c. If this procedure is not called, the default priority is 0 (shown in Table B3-4 Summary of SCB registers on page B3-710 of the ARMĀ®v7-M Architecture Reference Manual, ARM DDI 0403Derrata 2010_Q3 (ID100710)). If an SVC instruction is executed with the SVC hander, then it would attempt to run at a priority "equal to the currently executing priority" and, thus, would cause a HardFault. Note that there is no reason to issue an SVC from within an SVC handler because the SVC handler code is already running in handler mode (which is privileged).